/**
 * JAVACC DEMO 1.0
 * @copy right dwusoft company All rights reserved. 
 * @Package com.zbxsoft.utr.service.plugins  
 */
package com.apache.bid.service.adminplugins;

import java.util.Map;

import com.apache.api.vo.ParamsVo;
import com.apache.api.vo.ResultEntity;
import com.apache.bid.common.BidCommonUtil;
import com.apache.bid.common.Constant;
import com.apache.bid.common.WbdToolsUtil;
import com.apache.bid.service.plugins.UnitySaveSessionPluginImpl;
import com.apache.rpc.client.RpcProtoclClient;

/**
 * description:  新增session活动插件
 * 输入：ParamsVo（要新增的session实体）
 * 输出：sessionId（新增成功后生成的主键）
 * 业务：新增session、pub
 * @author xhe 创建时间：2016-03-21  
 * 
 */
public class SaveSessionInitPluginImpl extends UnitySaveSessionPluginImpl {

	@SuppressWarnings({ "rawtypes", "unchecked" })
	public Object execute(ParamsVo vo) throws Exception {
		ResultEntity entity = null;
		if (Constant.getInstance().ifWriteDatabase()) {
			entity = (ResultEntity) super.execute(vo);
		} else {
			Map map = WbdToolsUtil.getInstance().toMapDelNull(vo.getObj());
			map.putAll(vo.getParams());
			entity = RpcProtoclClient.getInstance().doService("wbdCacheService", "saveSession", map,
					BidCommonUtil.getInstance().getInterfaceRegister("", ""));
			log.info("result=" + entity.getResult() + ";msg=" + entity.getMessage());
		}
		return entity;
	}

}
